home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / binutils.7 / binutils / binutils-2.7 / gas / expr.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-04  |  5.2 KB  |  149 lines

  1. /* expr.h -> header file for expr.c
  2.    Copyright (C) 1987, 1992, 1993 Free Software Foundation, Inc.
  3.  
  4.    This file is part of GAS, the GNU Assembler.
  5.  
  6.    GAS is free software; you can redistribute it and/or modify
  7.    it under the terms of the GNU General Public License as published by
  8.    the Free Software Foundation; either version 2, or (at your option)
  9.    any later version.
  10.  
  11.    GAS is distributed in the hope that it will be useful,
  12.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.    GNU General Public License for more details.
  15.  
  16.    You should have received a copy of the GNU General Public License
  17.    along with GAS; see the file COPYING.  If not, write to
  18.    the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
  19.  
  20. /*
  21.  * By popular demand, we define a struct to represent an expression.
  22.  * This will no doubt mutate as expressions become baroque.
  23.  *
  24.  * Currently, we support expressions like "foo OP bar + 42".  In other
  25.  * words we permit a (possibly undefined) symbol, a (possibly
  26.  * undefined) symbol and the operation used to combine the symbols,
  27.  * and an (absolute) augend.  RMS says this is so we can have 1-pass
  28.  * assembly for any compiler emissions, and a 'case' statement might
  29.  * emit 'undefined1 - undefined2'.
  30.  *
  31.  * The type of an expression used to be stored as a segment.  That got
  32.  * confusing because it overloaded the concept of a segment.  I added
  33.  * an operator field, instead.
  34.  */
  35.  
  36. /* This is the type of an expression.  The operator types are also
  37.    used while parsing an expression.
  38.  
  39.    NOTE: This enumeration must match the op_rank array in expr.c.  */
  40.  
  41. typedef enum
  42. {
  43.   /* An illegal expression.  */
  44.   O_illegal,
  45.   /* A nonexistent expression.  */
  46.   O_absent,
  47.   /* X_add_number (a constant expression).  */
  48.   O_constant,
  49.   /* X_add_symbol + X_add_number.  */
  50.   O_symbol,
  51.   /* X_add_symbol + X_add_number - the base address of the image.  */
  52.   O_symbol_rva,
  53.   /* A register (X_add_number is register number).  */
  54.   O_register,
  55.   /* A big value.  If X_add_number is negative or 0, the value is in
  56.      generic_floating_point_number.  Otherwise the value is in
  57.      generic_bignum, and X_add_number is the number of LITTLENUMs in
  58.      the value.  */
  59.   O_big,
  60.   /* (- X_add_symbol) + X_add_number.  */
  61.   O_uminus,
  62.   /* (~ X_add_symbol) + X_add_number.  */
  63.   O_bit_not,
  64.   /* (! X_add_symbol) + X_add_number.  */
  65.   O_logical_not,
  66.   /* (X_add_symbol * X_op_symbol) + X_add_number.  */
  67.   O_multiply,
  68.   /* (X_add_symbol / X_op_symbol) + X_add_number.  */
  69.   O_divide,
  70.   /* X_add_symbol % X_op_symbol) + X_add_number.  */
  71.   O_modulus,
  72.   /* X_add_symbol << X_op_symbol) + X_add_number.  */
  73.   O_left_shift,
  74.   /* X_add_symbol >> X_op_symbol) + X_add_number.  */
  75.   O_right_shift,
  76.   /* X_add_symbol | X_op_symbol) + X_add_number.  */
  77.   O_bit_inclusive_or,
  78.   /* X_add_symbol |~ X_op_symbol) + X_add_number.  */
  79.   O_bit_or_not,
  80.   /* X_add_symbol ^ X_op_symbol) + X_add_number.  */
  81.   O_bit_exclusive_or,
  82.   /* X_add_symbol & X_op_symbol) + X_add_number.  */
  83.   O_bit_and,
  84.   /* X_add_symbol + X_op_symbol) + X_add_number.  */
  85.   O_add,
  86.   /* X_add_symbol - X_op_symbol) + X_add_number.  */
  87.   O_subtract,
  88.   /* (X_add_symbol == X_op_symbol) + X_add_number.  */
  89.   O_eq,
  90.   /* (X_add_symbol != X_op_symbol) + X_add_number.  */
  91.   O_ne,
  92.   /* (X_add_symbol < X_op_symbol) + X_add_number.  */
  93.   O_lt,
  94.   /* (X_add_symbol <= X_op_symbol) + X_add_number.  */
  95.   O_le,
  96.   /* (X_add_symbol >= X_op_symbol) + X_add_number.  */
  97.   O_ge,
  98.   /* (X_add_symbol > X_op_symbol) + X_add_number.  */
  99.   O_gt,
  100.   /* (X_add_symbol && X_op_symbol) + X_add_number.  */
  101.   O_logical_and,
  102.   /* (X_add_symbol || X_op_symbol) + X_add_number.  */
  103.   O_logical_or,
  104.   /* this must be the largest value */
  105.   O_max
  106. } operatorT;
  107.  
  108. typedef struct expressionS
  109. {
  110.   /* The main symbol.  */
  111.   struct symbol *X_add_symbol;
  112.   /* The second symbol, if needed.  */
  113.   struct symbol *X_op_symbol;
  114.   /* A number to add.  */
  115.   offsetT X_add_number;
  116.   /* The type of the expression.  */
  117.   unsigned X_op : 5;
  118.   /* Non-zero if X_add_number should be regarded as unsigned.  This is
  119.      only valid for O_constant expressions.  It is only used when an
  120.      O_constant must be extended into a bignum (i.e., it is not used
  121.      when performing arithmetic on these values).
  122.      FIXME: This field is not set very reliably.  */
  123.   unsigned int X_unsigned : 1;
  124. } expressionS;
  125.  
  126. /* "result" should be type (expressionS *). */
  127. #define expression(result) expr (0, result)
  128.  
  129. /* If an expression is O_big, look here for its value. These common
  130.    data may be clobbered whenever expr() is called. */
  131. /* Flonums returned here.  Big enough to hold most precise flonum. */
  132. extern FLONUM_TYPE generic_floating_point_number;
  133. /* Bignums returned here. */
  134. extern LITTLENUM_TYPE generic_bignum[];
  135. /* Number of littlenums in above. */
  136. #define SIZE_OF_LARGE_NUMBER (20)
  137.  
  138. typedef char operator_rankT;
  139.  
  140. extern char get_symbol_end PARAMS ((void));
  141. extern void expr_begin PARAMS ((void));
  142. extern segT expr PARAMS ((int rank, expressionS * resultP));
  143. extern unsigned int get_single_number PARAMS ((void));
  144. extern struct symbol *make_expr_symbol PARAMS ((expressionS * expressionP));
  145. extern int expr_symbol_where
  146.   PARAMS ((struct symbol *, char **, unsigned int *));
  147.  
  148. /* end of expr.h */
  149.